home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48hor1 / asc.txt < prev    next >
Text File  |  1995-03-31  |  6KB  |  139 lines

  1.  
  2.                       ASCII Encoding HP 48SX Objects 
  3.                               by Bill Wickes 
  4.  
  5. Sending an HP 48SX object via electronic mail can be difficult if the 
  6. object does not have an ASCII form, such as is the case for library 
  7. objects.  There are various encoding schemes available on different 
  8. computer systems, but these require that the sender and receiver have 
  9. similar computers, or at least compatible encode/decode schemes.  The 
  10. programs listed below perform the encoding and decoding on the HP 48SX itself, 
  11. which has the advantage of being completely independent of any computer. 
  12.  
  13. The programs are nominally called \->ASC and ASC\->.  The former takes an 
  14. object from the stack and converts it to a string, in which each nibble of the 
  15. object and its checksum is converted to a character 0-9 or A-F.  (The object 
  16. must be in RAM, otherwise a "ROM Object" error is returned.)  For sake of easy 
  17. inclusion in email letters, the string is broken up by linefeed characters 
  18. after every 64 characters. 
  19.  
  20. ASC\-> is the inverse of \->ASC: it takes a string created by \->ASC and 
  21. converts it back into an object.  When you transmit the encoded strings, 
  22. be sure not to change the string; ASC\-> uses the checksum encoded in the 
  23. string to verify that the decoding is correct.  An "Invalid String" error 
  24. is returned if the result object does not match the original object 
  25. encoded by \->ASC.  When you upload a string to your computer, use HP 48 
  26. translate mode 3 so that the HP 48 will convert any CR/LF's back to LF's 
  27. when the string is later downloaded. 
  28.  
  29. Two versions of ASC\-> are included here.  The first (P1) is in HP 48 user 
  30. language, using SYSEVALs to execute system objects.  P2 is a 
  31. string that the setup program uses P1 to decode into an executable 
  32. ASC\->--then P1 is discarded.  The second version is more 
  33. compact than the first, and also uneditable and therefore safer (but it can't 
  34. be transmitted in ASCII form, which helps to make the point of this exercise). 
  35.  
  36. [NOTE: You don't have to do all the following stuff to create ->ASC and 
  37. ASC->.  They are available, ready to run, in IO in the HORN2 directory on this 
  38. disk.  They are also in their own file, 'ASC', on the HORN1 disk.  -jkh-] 
  39.  
  40. Here are the programs, contained in a directory: 
  41.  
  42. (start) 
  43. %%HP: T(3)A(D)F(.); 
  44. DIR 
  45. P1              @ ASC\-> Version 1. 
  46. \<< 
  47.   IF DUP TYPE 2 \=/ 
  48.   THEN "Not A String" DOERR 
  49.   END RCWS \-> ws 
  50.   \<< 16 STWS 
  51.     #0 NEWOB SWAP DUP SIZE 
  52.     IF DUP 4 < 
  53.     THEN DROP SWAP DROP "Invalid String" DOERR 
  54.     END  
  55.     DUP 65 / IP - 4 - # 18CEAh SYSEVAL  
  56.     "" OVER # 61C1Ch SYSEVAL 
  57.     SWAP # 6641F8000AF02DCCh 
  58.     # 130480679BF8CC0h # 518Ah SYSEVAL 
  59.     # 19610313418D7EA4h # 518Ah SYSEVAL 
  60.     # 7134147114103123h # 518Ah SYSEVAL 
  61.     # 5F6A971131607414h # 518Ah SYSEVAL 
  62.     # 12EA1717EA3F130Ch # 518Ah SYSEVAL 
  63.     # 280826B3012808F4h # 518Ah SYSEVAL 
  64.     # 6B7028080BEE9091h # 518Ah SYSEVAL 
  65.     # BE5DC1710610C512h # 518Ah SYSEVAL 
  66.     # 705D00003431A078h # 518Ah SYSEVAL 
  67.     # 3D8FA26058961431h # 518Ah SYSEVAL 
  68.     # 312B0514h # 518Ah SYSEVAL  
  69.     # 18F23h SYSEVAL  
  70.     DUP BYTES DROP 4 ROLL 
  71.     IF == 
  72.     THEN SWAP DROP 
  73.     ELSE DROP "Invalid String" DOERR 
  74.     END ws STWS 
  75.   \>> 
  76. \>> 
  77.  
  78. P2    @ ASC\->  Version 2.  To be converted by ASC\-> version 1. 
  79.  
  80. "D9D20D29512BF81D0040D9D20E4A209000000007566074726636508813011920 
  81. 140007FE30B9F060ED3071040CA1304EC3039916D9D2085230B9F06C2A201200 
  82. 094E66716C696460235472796E676933A1B21300ED30FD5502C230C1C1632230 
  83. CCD20FA0008F14660CC8FB97608403104AE7D814313016913213014117414317 
  84. 414706131179A6F5C031F3AE7171AE214F8082103B6280821909EEB0808207B6 
  85. 215C0160171CD5EB870A13430000D50713416985062AF8D341508813044950B9 
  86. F06BBF06EFC36B9F0644230C2A201200094E66716C696460235472796E676933 
  87. A1B2130B21300373" 
  88.  
  89.  
  90. P3    @\->ASC.     To be converted by ASC\->. 
  91. "D9D20D2951881304495032230FD5502C230A752688130ADB467FE30322306AC3 
  92. 0CB916E0E30CBD30F6E30C1C1632230CCD20DC0008F14660CC8FB97608403104 
  93. AE7D8143130169174147061741431311534AC6B4415141534946908D9B026155 
  94. 4A6F53131F3AE731A014C161AE215F08082103A6280821939EEC08082170A621 
  95. 4C161170CD56B870A18503430000D5071351796A9F8D2D02639916D9D2085230 
  96. C2A209100025F4D402F426A6563647933A1B2130A2116B213033C0" 
  97.  
  98. SETUP    @Automatic setup program 
  99. \<< P2 P1 'ASC\->' STO 
  100.     P3 ASC\-> '\->ASC' STO 
  101.     { P1 P2 P3 SETUP } PURGE 
  102. \>> 
  103.  
  104. END 
  105. (end) 
  106.  
  107.  
  108. Installation instructions: 
  109.  
  110. 1.  Edit the above text between (start) and (end) into a text file named 
  111. CONV (for example).   
  112. Be sure that you leave the strings exactly as entered above, 
  113. with no extra spaces or other invisible characters at the beginnings or 
  114. ends of the lines. 
  115. 2.  Set the HP 48SX into ASCII transfer mode. 
  116. 3.  Using Kermit, download CONV text file to the 48, verify its checksum 
  117. (6C8Ah). 
  118. 4.  Execute CONV to make it the current directory. 
  119. 5.  Execute SETUP. 
  120. 6.  The directory CONV now contains ASC\-> and \->ASC, ready to use. 
  121.  
  122. To archive the decoded versions of ASC\-> and \->ASC back on your computer, 
  123. be sure to set the HP 48SX in binary transfer mode before uploading. 
  124.  
  125. Disclaimers: 
  126.  
  127. * Use the programs at your own risk.  Any time you delve into the SYSEVAL 
  128. world, there are increased dangers.  Archive your 48 memory before  
  129. experimenting with these programs!  Also, verify the checksums of objects 
  130. defined above to make sure they have been downloaded correctly, before 
  131. executing ASC\->. 
  132.  
  133. * I will not answer questions about how the programs work.  This is not 
  134. because of any great secrecy, but rather because it's hard to give 
  135. any answer that doesn't lead to more questions, and more, and more... 
  136.  
  137. * 48 hackers are welcome to mine any nuggets they can from the programs, 
  138. and from the fact that \->ASC is a convenient way to decompile an object. 
  139.